Computer graphics operations and components typically use scaled integers to represent fractional values. In an RGB color system, for example, the color of a particular pixel is represented as a scaled R (red) value, a scaled G (green) value, and a scaled B (blue) value. Technically, the full range of intensities for a particular color component ranges from 0 to 1, with intermediate intensities being represented by floating point values between 0.0 and 1.0. In actual implementation, however, it is much more convenient to use scaled integer values to represent these floating point numbers. Thus, when using so-called 24-bit color values, each RGB value is an 8-bit integer ranging from 0 to 255. A 0 value represents the lowest possible intensity of a particular color component (0.0), and a value of 255 represents a fully saturated color component (1.0). Intermediate values represent intensities that are fractions of the fill intensity.
Mathematically, the actual floating point intensity f is equal to i/s, where i is the integer representation of the intensity and s is a scaling factor. In the typical case where 1.0 is represented by the maximum possible value of an integer value, the scaling factor is equal to this maximum possible value. Thus, in the example above, the scaling factor is 255.
When performing graphics operations, there are many situations that require multiplying the intensity components of two different pixel values. Image compositing, blending, and antialiasing are examples of graphics operations that require pixel multiplication.
The scaled product r of two scaled integers a and b is equal to ab/s. The result of this calculation is rounded to obtain the nearest integer. A convenient way to perform such rounding is to add 0.5 to the result and truncate: r=trunc(ab/s+0.5), where "trunc" represents the truncation operator. To avoid floating point calculations, this can be rearranged as r=trunc[(ab+s/2)/s].
For 8-bit values of a and b, one of the inventors has previously demonstrated a method of multiplying scaled integers that is particularly efficient when using a computer or other programmable data processor to perform the calculations. This method was disclosed in Three Wrongs Make a Right ("IEEE Computer Graphics and Applications", November 1995, Volume 15, Number 6, pp. 90-93), which is hereby incorporated by reference. In accordance with this method, r=(i+(i&gt;&gt;8))&gt;&gt;8; where i=ab+128. The operator "&gt;&gt;" indicates a right-shift operation; "&gt;&gt;8" indicates a right-shift by 8 bits.
Using 80.times.86 assembly code, the operation above is performed most efficiently as follows:
______________________________________ mov al,a ;load a mul b ;multiply by b add ax,0x80 ;add bias add al,ah ;add ah to al adc ah,0 ;carry into ah mov r,ah ;store result ______________________________________
Although this assembly code represents an efficient programmed implementation of the equation r=(i+(i&gt;&gt;8))&gt;&gt;8, the inventors have recognized a need for a hardware implementation. Such a hardware implementation is needed in order to perform even more efficient graphics operations in conjunction with pixels represented by scaled integers. The particular hardware implementation described and claimed below is particularly efficient in terms of the number of electronic gates and components utilized.